/*Sejour Model*/
function SejourModel ($http) {
	function Sejour(SejourData) {
		if(SejourData){
			this.setData(SejourData);
		}
	};
	Sejour.prototype = {
		setData: function(SejourData) {
			angular.extend(this, SejourData);
		},
		ajouterSejour: function() {
            var promise = $http.post('/Sejour/ressource', this)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
            
        	return promise;
        },
        mettreAJourUnSejour: function (Sejour) {/*mettre à jour les données d'une Sejour*/
			var promise = $http.put('/Sejour/ressource?id='+Sejour.id, Sejour)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
        retourneSejours: function () {/*liste d'Sejours*/
			var promise = $http.get("/Sejour/ressource", this)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
		
			return promise;
		},
		retournerUnSejour: function (id) {
			var promise = $http.get('/Sejour/ressource?id='+id)
			.success(function (data, status, headers, config) {
				return data;
			})
			.error(function (data, status, headers, config) {
				return {"status": false};
			});
			
			return promise;
		},
		supprimerUnSejour: function (id) {/*supprime un séjour*/
			var promise = $http.delete('/Sejour/ressource?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
			return promise;
		},
		retourneThemesSejours: function () {/*tous les themes de séjours*/
			return [{"libelleThS": ""}, 
		        	{"libelleThS": "Enfant"}, 
		        	{"libelleThS": "Famille"}, 
		        	{"libelleThS": "S\351jour th\351matique"}];
		},
		retourneListesDonneesSejour: function () {
			var promise = $http.get('/Sejour/ChargerListesDonneesSejour')
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		/* DAYbyDAY SEJOUR */
		retourneDaybydaySejour: function (id) {
			var promise = $http.get('/Sejour/ressourceDaybyday?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		ajouterDaybydaySejour: function () {
			var promise = $http.post('/Sejour/ressourceDaybyday?id='+this.sejourId, this)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		supprimerDaybyday: function (id) {
			var promise = $http.delete('/Sejour/ressourceDaybyday?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
			return promise;
		},
		/* FICHE SEJOUR */
		retourneDetailsFicheSejour: function (id) {
			var promise = $http.get('/Sejour/ressourceFiche?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		ajouterFicheSejour: function () {
			var promise = $http.post('/Sejour/ressourceFiche?id='+this.sejourId, this)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		supprimerFicheSejour: function (id) {
			var promise = $http.delete('/Sejour/ressourceFiche?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
			return promise;
		},
		/* GALERIE IMAGES SEJOUR */
		retourneGalerieImagesSejour: function (id) {
			var promise = $http.get('/Sejour/ressourceImage?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		supprimerUneImageSejour: function (id) {
			var promise = $http.delete('/Sejour/ressourceImage?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
			return promise;
		},
		/* DISPONIBILITE SEJOUR */
		listeDisponibiliteEtats: function () {/*tous les différents états des disponibilités */
			return [{"libelleEtatDispo": ""}, 
		        	{"libelleEtatDispo": "Confirm\351"}, 
		        	{"libelleEtatDispo": "Ferm\351"}];
		},
		retourneDisponibilitesSejour: function (id) {
			var promise = $http.get('/Sejour/ressourceDisponibilites?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		ajouterDisponibiliteSejour: function () {/*Ajouter une nouvelle disponibilité au séjour*/
			var promise = $http.post('/Sejour/ressourceDisponibilites?id='+this.sejourId, this)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		supprimerUneDisponibilite: function (id) {
			var promise = $http.delete('/Sejour/ressourceDisponibilites?id='+id)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
			return promise;
		},
		/* CODE SEJOUR */
		rechercherNouveauCodeSejour: function () {
			var promise = $http.get('/Sejour/generercodesejour')
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
		verifierSiLeCodeSejourEstPris: function ( data ) {
			var promise = $http.post('/Sejour/iscodesejourdejapris', data)
				.success(function (data, status, headers, config) {
					return data;
				})
				.error(function (data, status, headers, config) {
					return {"status": false};
				});
	
			return promise;
		},
	};
	return Sejour;
}
